package com.dimples.dd.system.mapper;

import com.dimples.dd.common.pojo.PageResult;
import com.dimples.dd.mybatis.core.mapper.BaseMapperX;
import com.dimples.dd.mybatis.core.query.LambdaQueryWrapperX;
import com.dimples.dd.system.model.entity.SystemGatewayRouteDO;
import com.dimples.dd.system.model.query.GatewayRoutePageQuery;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SystemGatewayRouteMapper extends BaseMapperX<SystemGatewayRouteDO> {

    default PageResult<SystemGatewayRouteDO> selectGatewayRoutePage(GatewayRoutePageQuery pageQuery) {
        LambdaQueryWrapperX<SystemGatewayRouteDO> queryWrapperX = new LambdaQueryWrapperX<>();
        queryWrapperX
                .eqIfPresent(SystemGatewayRouteDO::getName, pageQuery.getName())
                .eqIfPresent(SystemGatewayRouteDO::getRouterId, pageQuery.getRouterId())
                .eqIfPresent(SystemGatewayRouteDO::getId, pageQuery.getId());
        return this.selectPage(pageQuery, queryWrapperX);
    }
}